#ifndef __PID_h_
#define __PID_h_
#include "headfile.h"


extern int Speed_base;
extern int L_Motor;
extern int R_Motor;

struct Speed_PID
{
	float kp;
	float ki;
	float kd;
	int error;
	int integral_error;
	int integral_error_max;
	int error_last;
	int error_last_last;
	int LocNum;
	int Speed_Dir_PID;
	float Set_speed;
};
extern struct Speed_PID Left;
extern struct Speed_PID Right;
extern struct Speed_PID Average;

 struct Chuan_Dir_PID
{
	float inner_kp;
	float inner_ki;
	float inner_kd;
	float outer_kp;
	float outer_kp_init;
	float outer_ki;
	float outer_kd;
	float gyro_now;
	float gyro_last;
	float gyro_error;
	float gyro_error_last;
	float gyro_integral;
	float actual_gyro_integral;
	float gyro_integral_max;
	float last_inner_expect;
	float inner_expect;
	float error;
	float error_last;
	float out;
	float last_out;
	float control_out;
  float i_split_flag;
  int control_out_max;
};
extern struct Chuan_Dir_PID Car_Direction;
extern struct Chuan_Dir_PID Gyroscope;

void PID_Init(void);
void Speed_PID_Average(void);
void Speed_PID_Left(void);
void Speed_PID_Right(void);
void Direction_Outer_Conrtol(void);
void Direction_Outer_Conrtol_Gyroscope(void);
void Direction_Inner_Control(void);
void Speed_XianFu(void);


#endif


